<template>
    <view style="height: 100%">
        <web-view  referrerPolicy='no-referrer' :src="gzh_url"></web-view>
        <view>
            {{ gzh_url }}
        </view>
    </view>
</template>

<script>
// pages/webview/webview.js
import http from '../../utils/http';
export default {
    data() {
        return {
            gzh_url: '',
			id:0
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad(options) {
		if(options.id){
			this.id = options.id
		}
		this.wxAuthLogin()
		// this.getUrl();
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {},
    methods: {
		wxAuthLogin() {
			let that = this;
			uni.login({
				complete: (res) => {
					let data = {
						code: res.code
					};
					let h = {
						'content-type': 'application/x-www-form-urlencoded'
					};
					uni.request({
						url: http.appUrl + 'login/getLogin',
						data: data,
						method: 'POST',
						header: h,
						success: (res) => {
							uni.setStorageSync('token', res.data.data.token.token);
							uni.setStorageSync('is_login', res.data.code);
						},
						fail: (res) => {
							console.log(res);
						},
						complete: () => {
							that.getUrl()
						}
					});
				}
			});
		},
        getUrl() {
            http.request('base/configData').then((res) => {
				if(this.id){
					this.gzh_url = res.data.FollowWithInterest 
				}else{
					this.gzh_url = res.data.gzh_url
				}
            });
        }
    }
};
</script>
<style>

</style>
